/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.azon.isip.detection.face;

import java.awt.Color;

/**
 *
 * @author Ahmad Fauzan
 */
public class FaceDetection {
    
    
    public int[][] doSegementation(int[][] imageMatrix) {
        int[][] result = new int[imageMatrix.length][imageMatrix[0].length];
        for(int i=0; i < result.length; i++) {
            for(int j=0; j < result[i].length; j++) {
                Color c = new Color(imageMatrix[i][j]);
                /*float Cb = -0.169f * c.getRed() - 0.332f * c.getGreen() + 0.5f * c.getBlue();
                float Cr = 0.5f * c.getRed() - 0.419f * c.getGreen() - 0.081f * c.getBlue();
                if(Cb < 0 && Cb > -17  && Cr > -10 && Cr < 20) {*/
                int B = c.getBlue();
                int R = c.getRed();
                int G = c.getGreen();
                if( R > 95 && G > 40 && B > 20 && R - Math.min(B, G) > 15 && R-G > 15 && R > G && R > B ) {
                //if(R > 105-22 && R < 105+22 && G > 107 - 22 && G < 107 + 22 && B > 95 - 22 && B < 95 + 22) {
                    Color newColor = new Color(1.0f , 1.0f, 1.0f);
                    result[i][j] = newColor.getRGB();
                }
            }
        }
        return result;
    }
}
